#include<bits/stdc++.h>
using namespace std;
#define int long long
int arr[101];
signed main()
{
	int n;

	while (cin >> n) {
		if (n == 0 ) {
			break;
		}
		int minn = 1e8;
		int index = 0;
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
			if(minn > arr[i]){
				index = i;
				minn = arr[i];
			}
		}
		arr[index] = arr[0];
		arr[0] = minn;
		for(int i=0;i<n;i++){
			cout << arr[i] << " ";
		}
		cout << endl;
		memset(arr,0,sizeof(arr));
	}
	return 0;
}
